package com.mjlf.mjatis;

import com.mjlf.mjatis.core.DefaultSqlSessionFactory;
import com.mjlf.mjatis.core.SqlSession;
import com.mjlf.mjatis.core.SqlSessionFactory;
import com.mjlf.mjatis.test.entity.User;
import com.mjlf.mjatis.test.mapper.UserDao;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.List;

/**
 * @ClassName Test
 * @Author mjlft
 * @Date 2020/5/22 16:45
 * @Version 1.0
 * @Description TODO
 */
public class Test {

    public static void main(String[] args) throws IOException {
        SqlSessionFactory sqlSessionFactory = new DefaultSqlSessionFactory();
        SqlSession sqlSession = sqlSessionFactory.buildSqlSession(new FileInputStream("D:\\project\\java\\mjatis\\src\\main\\resources\\mjtatis.json"));
        UserDao userDao =  sqlSession.getMapper(UserDao.class);
//        System.out.println(userDao.save(new User(2, "abc")));
//        System.out.println(userDao.getUser(1));
        System.out.println(userDao.getAll());
    }
}
